<template>
	<view class="center-contents-information">
		<view class="left-information">
			<view class="information-image">
				<image :src="urlImage + description?.z_name" mode="aspectFill"></image>
			</view>
			<view class="information-name">
				<view class="information-name-and-grade">
					<text>{{description?.z_name}}</text>
					<text>{{description?.Level?.title}}助教</text>
				</view>
			</view>
		</view>
	</view>
	<view class="current-day-money">
		<view class="current-day-money-contents">
			<view class="day-money-title">
				<text>当前价位：</text>
				<text>{{description?.Level?.price}}/小时</text>
			</view>
			<view class="assistant-grade">
				<text>当前档位：</text>
				<text>{{description?.Level?.title}}助教</text>
			</view>
		</view>
	</view>
	<view class="center-merchant">
		<view class="center-merchant-contents">
			<view class="center-contents">
				<view class="center-contents-title">
					<text>助教信息</text>
				</view>
				<view class="person-information-desc">
					<view class="person-desc-contents">
						<text>{{description?.z_introduce}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>

	<view class="fixed-content">
		<view class="fixed-button">
			<view class="button">
				<button @click="applyOrder(description)">立即下单</button>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import { postHttpsRequset, urlImage } from '../../public-ts-file/request';
	onLoad((options) => {
		const optionsID = options.id
		getDescription(optionsID)
	})
	const description = ref()
	const getDescription = (ids) => {
		const parms = {
			path: '/Zhujiao/info',
			methods: 'POST',
			data: {
				id: ids
			}
		}
		postHttpsRequset(parms).then(async res => {
			if (res.code == 200) {
				description.value = res.data
			}
		})
	}

	const applyOrder = (ids) => {
		const parms = {
			path: '/Order/add',
			methods: 'POST',
			data: {
				z_user_id: ids.id
			}
		}
		postHttpsRequset(parms).then(async res => {
			uni.showToast({
				title: '下单' + res.msg,
				icon: 'none'
			})
			if (res.code == 200) {
				setTimeout(() => {
					uni.redirectTo({
						url: '/pages/index/order'
					})
				}, 800)
			}
		})
	}
</script>

<style lang="scss" scoped>
	.center-merchant {
		border-top: 1px solid #FAFAFA;
		margin-top: 20rpx;
		padding-top: 20rpx;

		.center-merchant-contents {
			.center-contents {
				.center-contents-title {
					margin: 0 30rpx;

					text {
						font-size: 36rpx;
					}
				}

				.person-information-desc {
					margin: 0 30rpx;
					margin-top: 10rpx;

					.person-desc-contents {
						display: flex;
						flex-direction: column;

						text {
							font-size: 24rpx;
							color: #666666;
							font-weight: 400;
						}
					}
				}
			}
		}
	}

	.center-contents-information {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 0 30rpx;
		margin-top: 30rpx;

		.left-information {
			display: flex;
			align-items: center;

			.information-image {
				display: flex;
				align-items: center;
				position: relative;

				image {
					width: 80rpx;
					height: 80rpx;
					border-radius: 1000rpx;
				}

				&::after {
					content: '';
					position: absolute;
					width: 26rpx;
					height: 26rpx;
					background: #43CF7C;
					border: 4rpx solid white;
					right: -10rpx;
					bottom: -5rpx;
					border-radius: 100rpx;
					z-index: 1;
				}
			}

			.information-name {
				margin-left: 20rpx;

				.information-name-and-grade {
					text {
						font-size: 40rpx;
						font-weight: bold;

						&:nth-last-child(1) {
							font-size: 24rpx;
							color: #ccc;
							margin-left: 10rpx;
							font-weight: 400;
						}
					}
				}
			}
		}

		.information-right-money {
			text {
				color: #FF5733;
				font-size: 24rpx;
			}
		}
	}


	// 
	.current-day-money {
		margin-top: 30rpx;

		.current-day-money-contents {
			margin: 0 30rpx;

			.day-money-title {
				text {
					font-size: 26rpx;
					color: #999;

					&:nth-last-child(1) {
						font-size: 36rpx;
						color: #FF5733;
						font-weight: bold;
						font-family: 'SYHT';
					}
				}
			}

			.assistant-grade {
				margin-top: 3rpx;

				text {
					color: #999;
					font-size: 26rpx;

					&:nth-last-child(1) {
						color: #000;
					}
				}
			}
		}
	}

	.fixed-content {
		position: fixed;
		bottom: 0;
		width: 100%;
		background: white;
		box-shadow: 0 0 4rpx rgba(51, 119, 254, .25);

		.fixed-button {
			margin: 0 30rpx;
			padding: 20rpx 0;

			.button {
				button {
					padding: 2rpx 0;
					background: #3377FE;
					color: white;
					font-size: 28rpx;
					border-radius: 1000rpx;

					&::after {
						display: none;
						outline: none;
						border: none;
					}
				}
			}
		}
	}
</style>